import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    dataIndex: 'projectId_dictText'
  },
  {
    title: '所属部门',
    align: "center",
    dataIndex: 'departId_dictText'
  },
  {
    title: '发起人',
    align: "center",
    // dataIndex: 'createBy'
    dataIndex: 'promoter_dictText'
  },
  {
    title: '总工作量',
    align: "center",
    dataIndex: 'totalWorkload'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "所属部门",
    field: 'departId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_depart where org_type=2,depart_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "发起人",
    field: 'promoter',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_user,realname,username"
    },
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '所属部门',
    field: 'departId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "sys_depart where org_type=2,depart_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入所属部门!'},
             ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  departId: {title: '所属部门',order: 1,view: 'sel_search', type: 'string',dictTable: "sys_depart where org_type=2", dictCode: 'id', dictText: 'depart_name',},
  promoter: {title: '发起人',order: 2,view: 'sel_search', type: 'string',dictTable: "sys_user", dictCode: 'username', dictText: 'realname',},
  totalWorkload: {title: '总工作量',order: 3,view: 'number', type: 'number',},
};
